<?php
/**
 * User: jack<linjue@wilead.com>
 * Create At: 14/10/19
 */

namespace Wilead\IArtistBundle\Repository;

use Doctrine\ORM\EntityRepository;

/**
 * Class MomentsRepository
 * @package Wilead\IArtistBundle\Repository
 */
class MomentsRepository extends EntityRepository
{

    /**
     * @param array $ids
     * @return \Doctrine\ORM\QueryBuilder
     */
    public function getMomentsQueryBuilder($ids = array(), $uid)
    {
        $ids[] = $uid;
        return $this
            ->createQueryBuilder('q')
            ->select('q, u, a')
            ->leftJoin('q.User', 'u')
            ->leftJoin('q.Attachments', 'a')
            ->where('u.id IN (:ids)')
            ->orderBy('q.id', 'DESC')
            ->setParameter('ids', $ids);
    }
} 